Skip to main content

Directory Structure

backend/
├── plop-templates/ # Scaffolding for new code artifacts
│ ├── controller.hbs # Template for Controllers
│ ├── repository.hbs # Template for Repositories
│ ├── service.hbs # Template for Services
│ └── module-base/ # Base files for a new module
│ ├── container.ts.hbs
│ ├── index.ts.hbs
│ └── types.ts.hbs
├── src/ # Main TypeScript source
│ ├── bootstrap/ # Module loader and application startup
│ │ └── loadModules.ts # Dynamically imports and registers modules
│ ├── config/ # Environment & integration configs
│ │ ├── ai.ts # AI / GenAI credentials and setup
│ │ ├── app.ts # Express app configuration (CORS, bodyParser)
│ │ ├── db.ts # MongoDB connection pool and retry logic
│ │ ├── index.ts # Aggregates all config exports
│ │ ├── sentry.ts # Sentry initialization and instrumentation
│ │ ├── smtp.ts # Email SMTP transporter settings
│ │ └── storage.ts # Integration with cloud storage (e.g., GCS/S3)
│ ├── container.ts # InversifyJS DI container setup
│ ├── index.ts # Application entry point (bootstrapping)
│ ├── instrument.ts # Sentry instrumentation hooks
│ ├── inversify-adapter.ts# Adapter to integrate Inversify with routing-controllers
│ ├── modules/ # Domain modules, each with controllers/services/repos
│ │ ├── anomalies/ # User and course anomaly detection logic
│ │ ├── auth/ # Authentication and user management
│ │ ├── courses/ # Course and content management
│ │ ├── genAI/ # Generative AI integrations (e.g., question generation)
│ │ ├── notifications/ # Email, invites, and in-app notifications
│ │ ├── quizzes/ # Quiz engine: questions, attempts, grading
│ │ ├── settings/ # Proctoring and custom user/course settings
│ │ └── users/ # Enrollment, progress tracking, watch-time metrics
│ ├── shared/ # Reusable utilities and cross-cutting code
│ │ ├── classes/ # Base classes (e.g., BaseService, BaseRepository)
│ │ ├── constants/ # App-wide constants (status codes, roles)
│ │ ├── database/ # MongoDB client and connection helpers
│ │ ├── functions/ # Small utility functions (OpenAPI generation, auth checks)
│ │ ├── interfaces/ # TypeScript interfaces and DTO definitions
│ │ └── middleware/ # Express middleware (logging, error handling)
│ ├── types.ts # Global symbols and types for DI bindings
│ └── utils/ # Miscellaneous helper functions
│ ├── env.ts # Environment variable loader + validation
│ ├── index.ts # Re-export of utility functions
│ ├── logDetails.ts # Prints startup route summary and config
│ └── to-bool.ts # Safe boolean parsing from strings
├── .env # Local environment variables (gitignored)
├── .example.env # Sample `.env` with required keys
├── Dockerfile # Docker image for single-service deployment
├── Dockerfile-all # Docker image bundling all modules
├── firebase.json # Firebase project and auth config
├── package.json # NPM scripts and dependency list
├── plopfile.cjs # Plop generator configuration
├── tsconfig.json # TypeScript compiler settings
├── typedoc.json # API documentation config
├── vite.config.ts # (Optional) Frontend build config
└── README.md # High-level project overview

Why this structure?

  • Modularity: Each domain (modules/) is isolated for clear ownership and test boundaries.
  • Scaffold Consistency: plop-templates/ ensure new features follow a standard pattern (Controllers → Services → Repositories).
  • Separation of Concerns: Config, bootstrap, DI setup, and shared utilities each live in their own folders to reduce coupling.